package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.WikiData;
import com.thinkcube.edutainment.service.viewitem.WikiItem;
import com.thinkcube.edutainment.service.viewitem.WikiItem_;

@EBean
public class WikiAdapter extends BaseAdapter {

	List<WikiData> wikiData;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		WikiItem wikiItem;
		if (convertView == null) {
			wikiItem = WikiItem_.build(context);
		} else {
			wikiItem = (WikiItem) convertView;
		}

		wikiItem.bind(getItem(position));

		return wikiItem;
	}

	public List<WikiData> getTodoData() {
		return wikiData;
	}

	public void setTodoData(List<WikiData> wikiData) {
		this.wikiData = wikiData;
	}

	@Override
	public int getCount() {
		return wikiData.size();
	}

	@Override
	public WikiData getItem(final int position) {
		return wikiData.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
